
package edu.wpi.first.wpilibj.templates;

import edu.wpi.first.wpilibj.Ultrasonic;


public class MainClass 
{
    public static int pingchan;
    public static int echochan;
    
    public static Ultrasonic sonar;
    
   public MainClass( int a, int b )
   {
       pingchan = a;
       echochan = b;
   }
   
   public void initSonar()
   {
       sonar = new Ultrasonic( echochan, pingchan );
       sonar.setEnabled(true);
       sonar.setAutomaticMode(true);
   }
   
   public double getDistance()
   {
       if ( sonar.isRangeValid() )
       {
           return sonar.getRangeInches();
       }
       else
       {
           return 0;
       }
   }
   public double getFeet()
   {
       if ( sonar.isRangeValid() )
       {
           return sonar.getRangeInches() / 12;
       }
       else
       {
           return 0;
       }
   }
}
